(function(jQuery) {
	
	jQuery.fn.formAjax = function(pOptions) {
		
		var $form = jQuery(this);
		var _reqAjaxSubmit = null;
		
		var _defOptions = {
			before	: function() { return true; },
			after	: function() { return true; },
			dataType: 'html'
		}
		var _Options = jQuery.extend( _defOptions, pOptions );
		
		var _FormOptions = {
			url		: '',
			metodo	: ''
		}
		_FormOptions.url	= $form.attr( 'action' );
		_FormOptions.metodo	= $form.attr( 'method' );
		
		$form.unbind('submit').bind('submit', function(e) {
			
			e.preventDefault();
			var r = _Options.before.call();
			
			if ( r == false ) {
				return false;
			}
			
			var ajaxUrl			= _FormOptions.url;
			var ajaxMethod		= _FormOptions.metodo;
			var ajaxPars		= $form.serialize();
			var ajaxDataType	= _Options.dataType;
							
			_reqAjaxSubmit = jQuery.ajax( {
				dataType	: ajaxDataType,
				type		: ajaxMethod,
				data		: ajaxPars,
				url			: ajaxUrl,
				success: function( retornoSubmit )	{
					_Options.after.call( this, retornoSubmit, _reqAjaxSubmit );
				}
			});
			
		});
		
	}
	
})(jQuery);